<template>
    <div class="count-wrap">
        <div v-show="num">
            <span @click="count('-')">-</span>
            <span>{{num}}</span>
        </div>
        <span @click="count('+')">+</span>
    </div>
</template>
<script>
export default {
    props:{
        num:{
            type:Number,
            default:1
        },
        id:{
            type:Number
        }
    },
    methods:{
        count(str){
            let num;
            if(str === '+'){
                num = this.num + 1;
            }else{
                num = this.num - 1;
            }
            this.$bus.$emit('count',num,this.id)
        }
    }
}
</script>
<style lang="scss">
    .count-wrap{
        display: flex;
    }
</style>
